<?php
class Modulemanager_Model_Insertmodule implements Modulemanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_tokencheckout;
    
    private $modulemanager_data_insertsettings;
    private $insert_settings_result;
    private $modulemanager_data_insertmetavalues;
    private $insert_metavalues_result;
    private $modulemanager_data_insertcontentvalues;
    private $insert_contentvalues_result;
    
    private $action_handler;
    
    private $excepted_result = 1;
    
    public function __construct() {
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_tokencheckout = new Core_Controller_Tokencheckout;
        $this->modulemanager_data_insertsettings = new Modulemanager_Data_Insertsettings;
        $this->modulemanager_data_insertmetavalues = new Modulemanager_Data_Insertmetavalues;
        $this->modulemanager_data_insertcontentvalues = new Modulemanager_Data_Insertcontentvalues;
    }


    public function main(array $variables = null) {
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        $this->core_controller_tokencheckout = new Core_Controller_Tokencheckout;
        $this->core_controller_tokencheckout->main($variables['post']);
        $this->insert_settings_result = $this->modulemanager_data_insertsettings->main($variables);
        $this->insert_metavalues_result = $this->modulemanager_data_insertmetavalues->main($variables);
        $this->insert_contentvalues_result = $this->modulemanager_data_insertcontentvalues->main($variables);
        if(
                ($this->insert_settings_result == $this->excepted_result) &&
                ($this->insert_metavalues_result == $this->excepted_result) &&
                ($this->insert_contentvalues_result == $this->excepted_result)
                ){
            $this->action_handler = new Modulemanager_Data_Modulemanagerredirect;
            return $this->action_handler->main($variables);
            
        }
        else {
            $this->action_handler = new Modulemanager_Data_Moduleerrormessage;
            return $this->action_handler->main($variables);
        }
    }
}
